{% extends "base_content.html" %}
{% load engine_tags %}

{% block headtitle %}
    Edit Data: {{ data.name }}
{% endblock %}


{% block content %}
<div class="narrow">

    <div class="ui raised segment inputcolor">
    {% form_errors form %}
        <form method="post" class="ui form" action="{% url 'data_edit' data.uid %}" enctype="multipart/form-data">

            {% csrf_token %}

            <div class="field segment">
                <label>Name</label>
                {{ form.name }}
                <p class="muted">Edit the data name</p>
            </div>

            <div class="field">

                {% if form.file %}
                    {{ form.media }}
                    <label>File</label>
                    {{form.file}}
                    <p class="muted">Replace content of stored file with this one. <b>This does not change the name.</b></p>

                {% elif form.input_text %}
                    <label>Input Text</label>
                    <textarea rows="10" cols="55" name="{{form.input_text.name}}" id="id_{{form.input_text.name}}"
                          maxlength="{{ form.input_text.field.max_length }}">{% if form.input_text.value %}{{ form.input_text.value }}{% endif %}</textarea>
                    <p class="muted">Edit uploaded text ( {{ form.input_text.field.max_length }} characters ).</p>
                {% endif %}

            </div>
            <div class="ui small horizontal divider header">
            <i class="ui pen square icon"></i>Extra Information
            </div>

            <div class="field">
                <label>Data Type</label>
                {{ form.type }}
                <p class="muted">Data type used to sub-select during analysis.</p>
            </div>

            <div class="field segment">
                <label>Data description</label>
                {{ form.text }}
                <p class="muted">A detailed explanation of what is in the data collection (markdown OK).</p>
            </div>

            <button type="submit" class="ui submit green button">
                <i class="save icon"></i>Save
            </button>
            <a class="ui right floated button" href="{% url 'data_view' data.uid %}">
                <i class="undo icon"></i>Cancel
            </a>

        </form>
    </div>

{% endblock %}
